"""
获取exe文件的名称
"""

import win32gui

hwnd_file = dict()


def get_all_hwnd(hwnd, mouse):
    """
    :param hwnd: 句柄没
    :param mouse:
    :return: 所有的句柄
    """
    if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
        hwnd_file.update({hwnd: win32gui.GetWindowText(hwnd)})


win32gui.EnumWindows(get_all_hwnd, 0)


def is_has_hwnd(name):
    """
    :param name: 指定hwnd的名字
    :return: 是否存在该句柄名
    """
    res = False
    for hwnd in hwnd_file.values():
        if hwnd == name:
            res = True
            break
    return res


if __name__ == '__main__':
    # print(is_has_hwnd("EXStar"))
    for h, t in hwnd_file.items():
        if t != '':
            print(h, t)
